package com.team.sion.service.Impl;

import com.team.sion.mapper.SongListMapper;
import com.team.sion.pojo.Song;
import com.team.sion.pojo.SongList;
import com.team.sion.pojo.SongListExample;
import com.team.sion.service.SongListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SongListServiceImpl implements SongListService {
    @Autowired
    private SongListMapper songListMapper;

    @Override
    public List<SongList> findAll() {
        SongListExample example = new SongListExample();
        return songListMapper.selectByExample(example);
    }

    @Override
    public List<SongList> findByStyle(String style) {
        SongListExample example = new SongListExample();
        example.createCriteria().andStyleEqualTo(style);
        return songListMapper.selectByExample(example);
    }

    @Override
    public List<SongList> findByTitle(String title) {
        SongListExample example = new SongListExample();
        example.createCriteria().andTitleLike("%"+title+"%");
        return songListMapper.selectByExample(example);
    }

    @Override
    public List<Song> findById(Integer songListId) {
        return songListMapper.findById(songListId);
    }

    @Override
    public List<SongList> findBySongListId(Integer songListId) {
        SongListExample example = new SongListExample();
        example.createCriteria().andIdEqualTo(songListId);
        return songListMapper.selectByExample(example);
    }

    @Override
    public List<SongList> findAllByScore() {
        return songListMapper.selectByScore();
    }
}
